<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      :inline="true"
      v-show="showSearch"
      label-width="68px"
    >
      <!--  <el-form-item label="报表名称" prop="rptName">
        <el-input
          v-model="queryParams.rptName"
          placeholder="请输入报表名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <el-form-item label="记录时间" prop="rptTime">
        <el-date-picker
          :editable="false"
          clearable
          size="small"
          v-model="queryParams.rptTime"
          type="daterange"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          value-format="yyyy-MM-dd"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item label="审核人" prop="auditor">
        <el-input
          v-model="queryParams.auditor"
          placeholder="请输入审核人"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="操作人" prop="operator">
        <UserDialog
          @dialogChange="queryParams.operator = $event.label"
          :echoValue="queryParams.operator"
          :multiple="false"
          placeholder="请选择人员"
        />
        <!-- <el-input
          v-model="queryParams.operator"
          placeholder="请输入操作人"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        /> -->
        <!--<el-select
          v-model="queryParams.operator"
          filterable
          allow-create
          placeholder="请选择操作人"
          style="width: 100%"
          @keyup.enter.native="handleQuery"
        >
          <el-option
            v-for="item in userList"
            :key="item.nickName"
            :label="item.nickName"
            :value="item.nickName"
          ></el-option>
        </el-select>-->
      </el-form-item>
      <!-- <el-form-item label="报表编码" prop="code">
        <el-input
          v-model="queryParams.code"
          placeholder="请输入报表编码"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="工厂名称" prop="factory">
        <el-input
          v-model="queryParams.factory"
          placeholder="请输入工厂名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="设备类型" prop="rptType">
        <el-select
          v-model="queryParams.rptType"
          placeholder="请选择设备类型"
          clearable
          size="small"
        >
          <el-option label="请选择字典生成" value="" />
        </el-select>
      </el-form-item> -->
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['report:paperpack:add']"
          >新增</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['report:paperpack:edit']"
          >修改</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['report:paperpack:remove']"
          >删除</el-button
        >
      </el-col>
      <!-- <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['report:paperpack:export']"
          >导出</el-button
        >
      </el-col> -->
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-s-check"
          size="mini"
          :disabled="multiple"
          @click="handleCheck"
          v-hasPermi="['report:paperpack:check']"
          >审核</el-button
        >
      </el-col>
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>

    <el-table
      v-loading="loading"
      :data="paperpackList"
      @selection-change="handleSelectionChange"
      max-height="550"
    >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="编号" align="center" prop="id" width="80px" />
      <!-- <el-table-column label="报表名称" align="center" prop="rptName" /> -->
      <el-table-column
        label="记录时间"
        align="center"
        prop="rptTime"
        width="180"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.rptTime, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column label="报表编码" align="center" prop="code" min-width="150px"/>
      <el-table-column label="工厂名称" align="center" prop="factory" min-width="150px"/>
      <el-table-column label="设备类型" align="center" prop="rptType" />
      <el-table-column label="操作人" align="center" prop="operator" />
      <el-table-column label="审核人" align="center" prop="auditor" />
      <!-- <el-table-column label="备注" align="center" prop="remark" /> -->
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
        min-width="250px"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-view"
            @click="excelhandleView(scope.row)"
          >导出</el-button            >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['report:paperpack:edit']"
          >修改</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-view"
            @click="handleView(scope.row)"
            >查看</el-button
          >

          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['report:paperpack:remove']"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改纸包机操作记录对话框 -->
    <el-dialog
      fullscreen
      :title="title"
      :visible.sync="open"
      width="900px"
      append-to-body
      custom-class="myDialog"
      :destroy-on-close="true"
    >
      <TableHeader
        @nameChange="nameChange"
        @nameChange2="nameChange2"
        :data="{
          mainTitle: '纸包机操作记录',
          company: form.factory,
          code: form.code,
        }"
      />
      <el-form ref="form" :model="form" :rules="rules" label-width="90px">
        <el-row>
          <!-- <el-col :span="12">
                <el-form-item label="报表名称" prop="rptName">
                  <el-input v-model="form.rptName" placeholder="请输入报表名称" :disabled="openDisabled" />
                </el-form-item>
            </el-col> -->
          <el-col :span="12">
            <el-form-item label="记录日期" prop="rptTime">
              <el-date-picker
                :editable="false"
                clearable
                size="small"
                v-model="form.rptTime"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择记录时间"
                :disabled="openDisabled"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>

          <!-- <el-col :span="12">
                <el-form-item label="报表编码" prop="code">
                  <el-input v-model="form.code" placeholder="请输入报表编码" :disabled="openDisabled" />
                </el-form-item>
            </el-col>
            <el-col :span="12">
                <el-form-item label="工厂名称" prop="factory">
                  <el-input v-model="form.factory" placeholder="请输入工厂名称" :disabled="openDisabled" />
                </el-form-item>
            </el-col>
            <el-col :span="12">
                <el-form-item label="设备类型" prop="rptType">
                  <el-select v-model="form.rptType" placeholder="请选择设备类型" :disabled="openDisabled">
                    <el-option label="请选择字典生成" value="" />
                  </el-select>
                </el-form-item>
            </el-col> -->
        </el-row>

        <!-- 纸包机操作记录时间信息 -->
        <el-divider content-position="center"></el-divider>
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button
              type="primary"
              icon="el-icon-plus"
              size="mini"
              @click="handleAddRptProPaperpack"
              :disabled="openDisabled"
              >添加</el-button
            >
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="danger"
              icon="el-icon-delete"
              size="mini"
              @click="handleDeleteRptProPaperpack"
              :disabled="openDisabled"
              >删除</el-button
            >
          </el-col>
        </el-row>
        <el-divider content-position="center">基本信息</el-divider>
        <br />
        <el-table
          :data="rptProPaperpackList"
          :row-class-name="rowRptProPaperpackIndex"
          @selection-change="handleRptProPaperpackSelectionChange"
          ref="rptProPaperpack"

        >
          <el-table-column type="selection" minWidth="50" align="center" />
          <!--  <el-table-column
            label="序号"
            align="center"
            prop="index"
            minWidth="50"
          /> -->
          <el-table-column label="产品名称" prop="productName">
            <template slot-scope="scope">
              <!-- <el-input
                v-model="scope.row.productName"
                placeholder="请输入产品名称"
                :disabled="openDisabled"
              /> -->
              <!-- <el-select
                v-model="scope.row.productName"
                placeholder="请选择产品名称"
                style="width: 100%"
                :disabled="openDisabled"
              >
                <el-option
                  v-for="dict in report_paperpack_cpmc"
                  :key="dict.index"
                  :label="dict.dictLabel"
                  :value="dict.dictLabel"
                ></el-option>
              </el-select> -->
              <Dialog
                @dialogChange="dialogChange($event, scope)"
                :echoValue="scope.row.ggname"
                parameter="rows"
                value="id"
                label="name"
                :multiple="false"
                search="name/code"
                url="/basic/productInfo/listSelect"
                :column="['产成品编号/code', '产成品名称/name']"
                placeholder="请选择内容"
                :axiosData="{typeCode: 'YYTRKQS'}"
                :openDisabled="openDisabled"
              />
            </template>
          </el-table-column>
          <el-table-column label="开机时间" prop="startTime">
            <template slot-scope="scope">
              <el-time-picker
                :editable="false"
                clearable
                v-model="scope.row.startTime"
                value-format="HH:mm"
                format="HH:mm"
                placeholder="选择开机时间"
                :disabled="openDisabled"
              >
              </el-time-picker>
            </template>
          </el-table-column>
          <el-table-column label="停机时间" prop="stopTime">
            <template slot-scope="scope">
              <el-time-picker
                :editable="false"
                clearable
                v-model="scope.row.stopTime"
                value-format="HH:mm"
                format="HH:mm"
                placeholder="选择停机时间"
                :disabled="openDisabled"
              >
              </el-time-picker>
            </template>
          </el-table-column>
          <el-table-column label="机速（箱/分）" prop="js">
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.js"
                placeholder="请输入机速"
                :disabled="openDisabled"
                type="number"
              />
            </template>
          </el-table-column>
         <!--  <el-table-column label="操作">
            <template slot-scope="scope">
              <el-button
                type="primary"
                plain
                icon="el-icon-search"
                @click="handleDate(scope)"
                >读取数据</el-button
              >
            </template>
          </el-table-column> -->
          <!--  <el-table-column label="备注" prop="remark">
            <template slot-scope="scope">
                <el-input v-model="scope.row.remark" type="textarea" placeholder="请输入内容" :disabled="openDisabled"/>
            </template>
          </el-table-column> -->
        </el-table>
        <br />
        <!-- 纸包机操作记录温度信息 -->
        <br />
        <el-divider content-position="center">每日记录</el-divider>
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button
              type="primary"
              icon="el-icon-plus"
              size="mini"
              @click="handleAddRptProPaperpackDay"
              :disabled="openDisabled"
              >添加</el-button
            >
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="danger"
              icon="el-icon-delete"
              size="mini"
              @click="handleDeleteRptProPaperpackDay"
              :disabled="openDisabled"
              >删除</el-button
            >
          </el-col>
        </el-row>
        <el-divider content-position="center"></el-divider>
        <el-table
          :data="rptProPaperpackDayList"
          :row-class-name="rowRptProPaperpackDayIndex"
          @selection-change="handleRptProPaperpackDaySelectionChange"
          ref="rptProPaperpackDay"
        >
          <el-table-column type="selection" minWidth="50" align="center" />
          <!-- <el-table-column
            label="序号"
            align="center"
            prop="index"
            minWidth="50"
          /> -->
          <el-table-column label="热熔胶型号" prop="rrjxh" minWidth="180">
            <template slot-scope="scope">
              <!-- <el-input
                v-model="scope.row.rrjxh"
                placeholder="请输入热熔胶型号"
                :disabled="openDisabled"
              /> -->
              <el-select
                v-model="scope.row.rrjxh"
                placeholder="请选择热熔胶型号"
                style="width: 100%"
                :disabled="openDisabled"
              >
                <el-option
                  v-for="dict in report_paperpack_rrj"
                  :key="dict.index"
                  :label="dict.dictLabel"
                  :value="dict.dictLabel"
                ></el-option>
              </el-select>
            </template>
          </el-table-column>
          <el-table-column label="热熔胶领用量" prop="rrjlyl" minWidth="180">
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.rrjlyl"
                placeholder="请输入热熔胶领用量"
                :disabled="openDisabled"
                type="number"
                @change="calculate(scope)"
              />
            </template>
          </el-table-column>
          <el-table-column label="热熔胶剩余量" prop="rrjleft" minWidth="180">
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.rrjleft"
                placeholder="请输入热熔胶剩余量"
                :disabled="openDisabled"
                type="number"
                @change="calculate(scope)"
              />
            </template>
          </el-table-column>
          <el-table-column label="热熔胶使用量" prop="rrjsyl" minWidth="180">
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.rrjsyl"
                placeholder="请输入热熔胶使用量"
                :disabled="openDisabled"
                type="number"
              />
            </template>
          </el-table-column>
          <el-table-column label="记录时间" prop="recordTime" minWidth="140">
            <template slot-scope="scope">
              <el-time-picker
                :editable="false"
                clearable
                v-model="scope.row.recordTime"
                value-format="HH:mm"
                format="HH:mm"
                placeholder="选择记录时间"
                :disabled="openDisabled"
              >
              </el-time-picker>
            </template>
          </el-table-column>
          <el-table-column label="胶箱温度" prop="jxwd" minWidth="150">
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.jxwd"
                placeholder="请输入胶箱温度"
                :disabled="openDisabled"
                type="number"
              />
            </template>
          </el-table-column>
          <el-table-column label="胶管温度" prop="jgwd" minWidth="100">
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.jgwd"
                placeholder="请输入胶管温度"
                :disabled="openDisabled"
                  type="number"
              />
            </template>
          </el-table-column>
          <el-table-column label="胶枪温度" prop="jqwd" minWidth="150">
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.jqwd"
                placeholder="请输入胶枪温度"
                :disabled="openDisabled"
                type="number"
              />
            </template>
          </el-table-column>

          <!-- <el-table-column label="备注" prop="remark">
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.remark"
                type="textarea"
                placeholder="请输入内容"
                :disabled="openDisabled"
              />
            </template>
          </el-table-column> -->
        </el-table>
        <br />
        <!-- 纸包机操作记录岗位自检情况信息 -->
        <br />
        <el-divider content-position="center">岗位自检情况</el-divider>
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button
              type="primary"
              icon="el-icon-plus"
              size="mini"
              @click="handleAddRptProPaperpackCheck"
              :disabled="openDisabled"
              >添加</el-button
            >
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="danger"
              icon="el-icon-delete"
              size="mini"
              @click="handleDeleteRptProPaperpackCheck"
              :disabled="openDisabled"
              >删除</el-button
            >
          </el-col>
        </el-row>
        <el-divider content-position="center"></el-divider>
        <el-table
          :data="rptProPaperpackCheckList"
          :row-class-name="rowRptProPaperpackCheckIndex"
          @selection-change="handleRptProPaperpackCheckSelectionChange"
          ref="rptProPaperpackCheck"
           max-height="550"
        >
          <el-table-column type="selection" minWidth="50" align="center" />
          <!-- <el-table-column
            label="序号"
            align="center"
            prop="index"
            minWidth="50"
          /> -->
          <el-table-column label="记录时间" prop="recordTime" minWidth="140">
            <template slot-scope="scope">
              <el-time-picker
                :editable="false"
                clearable
                v-model="scope.row.recordTime"
                value-format="HH:mm"
                format="HH:mm"
                placeholder="选择记录时间"
                :disabled="openDisabled"
              >
              </el-time-picker>
            </template>
          </el-table-column>
          <el-table-column label="封箱质量" prop="fxzl" minWidth="150">
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.fxzl"
                placeholder="请输入封箱质量"
                :disabled="openDisabled"
              />
              <!-- <el-select v-model="scope.row.fxzl" :disabled="openDisabled">
                <el-option value="正常">正常</el-option>
                <el-option value="异常">异常</el-option>
              </el-select> -->
            </template>
          </el-table-column>
          <el-table-column label="缺瓶检查" prop="qpjc" minWidth="150">
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.qpjc"
                placeholder="请输入缺瓶检查"
                :disabled="openDisabled"
              />
              <!-- <el-select v-model="scope.row.qpjc" :disabled="openDisabled">
                <el-option value="正常">正常</el-option>
                <el-option value="异常">异常</el-option>
              </el-select> -->
            </template>
          </el-table-column>
          <el-table-column label="粘合情况" prop="nhqk" minWidth="150">
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.nhqk"
                placeholder="请输入粘合情况"
                :disabled="openDisabled"
              />
              <!-- <el-select v-model="scope.row.nhqk" :disabled="openDisabled">
                <el-option value="正常">正常</el-option>
                <el-option value="异常">异常</el-option>
              </el-select> -->
            </template>
          </el-table-column>
          <el-table-column label="瓶码" prop="pm" minWidth="180">
            <template slot-scope="scope">
              <!-- <el-input
                v-model="scope.row.pm"
                placeholder="请输入瓶码"
                :disabled="openDisabled"
              /> -->
              <ImageUpload
                :limit="1"
                @input="scope.row.pm = $event"
                v-if="isShowImageUpload"
              ></ImageUpload>
              <img
                :src="scope.row.pm"
                style="width: 200px; height: 100px"
                v-if="scope.row.pm != ''"
              />
            </template>
          </el-table-column>
          <el-table-column label="瓶码(手录)" prop="pmHand" minWidth="180">
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.pmHand"
                placeholder=""
                :disabled="openDisabled"

              />
            </template>
          </el-table-column>

          <el-table-column label="箱码" prop="xm" minWidth="180">
            <template slot-scope="scope">
              <!-- <el-input
                v-model="scope.row.xm"
                placeholder="请输入箱码"
                :disabled="openDisabled"
              /> -->
              <ImageUpload
                :limit="1"
                @input="scope.row.xm = $event"
                v-if="isShowImageUpload"
              ></ImageUpload>
              <img
                :src="scope.row.xm"
                style="width: 200px; height: 100px"
                v-if="scope.row.xm != ''"
              />
            </template>
          </el-table-column>
          <el-table-column label="箱码(手录)" prop="xmHand" minWidth="180">
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.xmHand"
                placeholder="请输入夹紧阀压力"
                :disabled="openDisabled"

              />
            </template>
          </el-table-column>
          <el-table-column label="纸箱条形码" prop="zxtxm" minWidth="170">
            <template slot-scope="scope">
              <!-- <el-input
                v-model="scope.row.zxtxm"
                placeholder="请输入纸箱条形码"
                :disabled="openDisabled"
              /> -->
              <el-select
                v-model="scope.row.zxtxm"
                placeholder="请选择纸箱条形码"
                style="width: 100%"
                :disabled="openDisabled"
              >
                <el-option
                  v-for="dict in report_paperpack_txm"
                  :key="dict.index"
                  :label="dict.dictLabel"
                  :value="dict.dictLabel"
                ></el-option>
              </el-select>
            </template>
          </el-table-column>
          <!-- <el-table-column label="备注" prop="remark">
            <template slot-scope="scope">
                <el-input v-model="scope.row.remark" type="textarea" placeholder="请输入内容" :disabled="openDisabled"/>
            </template>
          </el-table-column> -->
        </el-table>

        <!-- 纸包机操作记录纸箱使用情况信息 -->
        <br />
        <el-divider content-position="center">纸箱使用情况</el-divider>
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button
              type="primary"
              icon="el-icon-plus"
              size="mini"
              @click="handleAddRptProPaperpackState"
              :disabled="openDisabled"
              >添加</el-button
            >
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="danger"
              icon="el-icon-delete"
              size="mini"
              @click="handleDeleteRptProPaperpackState"
              :disabled="openDisabled"
              >删除</el-button
            >
          </el-col>
        </el-row>
        <br />
        <el-divider content-position="center"></el-divider>
        <el-table
          :data="rptProPaperpackStateList"
          :row-class-name="rowRptProPaperpackStateIndex"
          @selection-change="handleRptProPaperpackStateSelectionChange"
          ref="rptProPaperpackState"
        >
          <el-table-column type="selection" minWidth="50" align="center" />
          <!-- <el-table-column
            label="序号"
            align="center"
            prop="index"
            minWidth="50"
          /> -->
          <el-table-column label="纸箱供应商" prop="gys">
            <template slot-scope="scope">
              <!-- <el-select
                v-model="scope.row.zxgys"
                placeholder="请选择纸箱供应商"
                style="width: 100%"
                :disabled="openDisabled"
              >
                <el-option
                  v-for="dict in report_paperpack_gys"
                  :key="dict.index"
                  :label="dict.dictLabel"
                  :value="dict.dictLabel"
                ></el-option>
              </el-select> -->
              <!-- <treeselect :searchable="false"
                v-model="scope.row.gys"
                :options="deptOptions"
                zIndex="9999"
                :appendToBody="true"
                :normalizer="normalizer"
                placeholder="请选择设备厂家"

              /> -->
              <ReportDialog
                @dialogChange="scope.row.gys = $event.value"
                :echoValue="scope.row.gys"
                value="id"
                label="label"
                placeholder="选择设备厂家"
                :openDisabled="openDisabled"
              />
            </template>
          </el-table-column>
          <el-table-column label="不合格数量" prop="bhenum">
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.bhenum"
                placeholder="请输入不合格数量"
                :disabled="openDisabled"
                type="number"
              />
            </template>
          </el-table-column>
          <el-table-column label="不合格原因" prop="bhgreason">
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.bhgreason"
                placeholder="请输入不合格原因"
                :disabled="openDisabled"
              />
            </template>
          </el-table-column>
          <!-- <el-table-column label="备注" prop="remark">
            <template slot-scope="scope">
                <el-input v-model="scope.row.remark" type="textarea" placeholder="请输入内容" :disabled="openDisabled"/>
            </template>
          </el-table-column> -->
        </el-table>

        <br />
        <el-divider content-position="center">纸包机交接班信息</el-divider>
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button
              type="primary"
              icon="el-icon-plus"
              size="mini"
              @click="handleAddRptProPaperpackWork"
              :disabled="openDisabled"
              >添加</el-button
            >
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="danger"
              icon="el-icon-delete"
              size="mini"
              @click="handleDeleteRptProPaperpackWork"
              :disabled="openDisabled"
              >删除</el-button
            >
          </el-col>
        </el-row>
        <el-table
          :data="rptProPaperpackWorkList"
          :row-class-name="rowRptProPaperpackWorkIndex"
          @selection-change="handleRptProPaperpackWorkSelectionChange"
          ref="rptProPaperpackWork"
        >
          <el-table-column type="selection" minWidth="50" align="center" />
          <el-table-column
            label="序号"
            align="center"
            prop="index"
            minWidth="50"
          />
          <el-table-column label="开始时间" prop="recordTime">
            <template slot-scope="scope">
              <el-time-picker
                :editable="false"
                clearable
                v-model="scope.row.recordTime"
                value-format="HH:mm"
                format="HH:mm"
                placeholder="选择记录时间"
                :disabled="openDisabled"
              >
              </el-time-picker>
            </template>
          </el-table-column>
          <el-table-column label="结束时间" prop="recordTime2">
            <template slot-scope="scope">
              <el-time-picker
                :editable="false"
                clearable
                v-model="scope.row.recordTime2"
                value-format="HH:mm"
                format="HH:mm"
                placeholder="选择记录时间"
                :disabled="openDisabled"
              >
              </el-time-picker>
            </template>
          </el-table-column>

          <el-table-column label="人员" prop="userid">
            <template slot-scope="scope">
              <!-- <el-input v-model="scope.row.persons" placeholder="请输入人员" :disabled="openDisabled"/> -->
              <Dialog
                @dialogChange="dialogChangeUser($event, scope)"
                :echoValue="scope.row.username"
                parameter="rows"
                value="userId"
                label="nickName"
                :multiple="true"
                search="nickName/userId"
                url="/system/user/list"
                :column="['用户ID/userId', '用户名称/nickName']"
                placeholder="请选择内容"
                :openDisabled="openDisabled"
              />
            </template>
          </el-table-column>

          <!-- <el-table-column label="状态" prop="workstate">
            <template slot-scope="scope">
              <el-select v-model="scope.row.workstate">
                <el-option value="上班">上班</el-option>
                <el-option value="下班">下班</el-option>
              </el-select>
            </template>
          </el-table-column> -->
          <!-- <el-table-column label="备注" prop="remark">
            <template slot-scope="scope">
                <el-input v-model="scope.row.remark" type="textarea" placeholder="请输入内容" :disabled="openDisabled"/>
            </template>
          </el-table-column> -->
        </el-table>

        <!-- 交接班 -->
        <!-- <el-col :span="24">
          <el-form-item label="交接班情况" prop="jjb">
            <el-input
              v-model="form.jjb"
              placeholder="请输入交接班情况"
              :disabled="openDisabled"
            />
          </el-form-item>
        </el-col> -->

        <!-- 审核 -->
        <el-col :span="24">
          <el-form-item label="备注" prop="remark">
            <el-input
              v-model="form.remark"
              type="textarea"
              placeholder="请输入内容"
              :disabled="openDisabled"
            />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="审核人" prop="auditor">
            <el-input
              v-model="form.auditor"

              :disabled="true"
            />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="操作人" prop="operator">
            <UserDialog
              @dialogChange="form.operator = $event.label"
              :echoValue="form.operator"
              :multiple="false"
              :openDisabled="openDisabled"
              placeholder="请选择人员"
            />
            <!-- <el-input
              v-model="form.operator"
              placeholder="请输入操作人"
              :disabled="openDisabled"
            /> -->
            <!--<el-select
              v-model="form.operator"
              filterable
              allow-create
              placeholder="请选择操作人"
              style="width: 100%"
              :disabled="openDisabled"
            >
              <el-option
                v-for="item in userList"
                :key="item.nickName"
                :label="item.nickName"
                :value="item.nickName"
              ></el-option>
            </el-select>-->
          </el-form-item>
        </el-col>
      </el-form>
      <div slot="footer" class="dialog-footer" v-if="!openDisabled">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listPaperpack,
  getPaperpack,
  delPaperpack,
  addPaperpack,
  updatePaperpack,
    checkPaperpack,
  handleDate,
} from "@/api/report/process/paperpack";
import { listEqpfactory } from "@/api/basic/eqpfactory/eqpfactory";
import { getInfo } from "@/api/login";
import { listUser } from "@/api/system/user";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";

export default {
  name: "Paperpack",
  components: { Treeselect },
  data() {
    return {
      /* 当前用户名 */
      nickName: "",
      userList: [],
      //弹窗是否禁止编辑
      openDisabled: true,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 子表选中数据
      checkedRptProPaperpackDay: [],
      // 上传组件的显示
      isShowImageUpload: true,
      // 树选项
      deptOptions: [],
      // 图片的预览
      isShowImage: false,
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 纸包机操作记录表格数据
      paperpackList: [],
      // 纸包机操作记录温度表格数据
      rptProPaperpackDayList: [],
      // 纸包机操作记录时间表格数据
      rptProPaperpackList: [],
      // 纸包机操作记录岗位自检情况表格数据
      rptProPaperpackCheckList: [],
      // 纸包机操作记录纸箱使用情况表格数据
      rptProPaperpackStateList: [],
      rptProPaperpackWorkList: [],
      // 子表选中数据
      checkedRptProPaperpackWork: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 50,
        rptName: null,
        rptTime: null,
        rptTime1: null,

        auditor: null,
        operator: null,
        code: null,
        factory: null,
        rptType: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
    };
  },
  created() {
    this.getList();
    this.queryUserList();
    this.getDicts("report_paperpack_cpmc").then((response) => {
      this.report_paperpack_cpmc = response.data;
    });
    this.getDicts("report_paperpack_rrj").then((response) => {
      this.report_paperpack_rrj = response.data;
    });
    this.getDicts("report_paperpack_txm").then((response) => {
      this.report_paperpack_txm = response.data;
    });
    this.getDicts("report_paperpack_gys").then((response) => {
      this.report_paperpack_gys = response.data;
    });
  },
  methods: {
    calculate(scope){
      let row = scope.row;
      if(row.rrjlyl != '' && row.rrjleft != ''){
        this.rptProPaperpackDayList[scope.$index].rrjsyl = Number(row.rrjlyl) - Number(row.rrjleft);
      }

    },
    /** 转换数据结构 */
    normalizer(node) {
      if (node.children && !node.children.length) {
        delete node.children;
      }
      return {
        id: node.id,
        label: node.name,
        children: node.children,
      };
    },
    // 读取数据
    handleDate(scope) {
      // console.log(scope);
      if (this.form.rptTime == "" || this.form.rptTime == null) {
        this.msgError("请输入记录日期");
      } else {
        const start = scope.row.startTime;
        const end = scope.row.stopTime;
        const start1 = this.form.rptTime + " " + start;
        const end1 = this.form.rptTime + " " + end;

        if (start == "" || start == null) {
          this.msgError("请输入开始时间");
        } else if (end == "" || end == null) {
          this.msgError("请输入结束时间");
        } else {
          // 调取接口
          handleDate({
            startTime: start1 + ":00",
            stopTime: end1 + ":00",
          }).then((res) => {
            this.rptProPaperpackList[scope.$index].js = res.data.js;
          });
        }
      }
    },
    dialogChangeUser(event, scope) {
      // // console.log(scope);
      this.rptProPaperpackWorkList[scope.$index].userid = event.value;
      this.rptProPaperpackWorkList[scope.$index].username = event.label;
      // console.log(this.rptProArrangesub1List)
    },
    dialogChange(event, scope) {
      // // console.log(scope);
      this.rptProPaperpackList[scope.$index].gg = event.options.code;
      this.rptProPaperpackList[scope.$index].ggname = event.label;
      // console.log(this.rptProArrangesub1List)
    },
    dialogChangeFactory(event, scope) {
      this.rptProPaperpackStateList[scope.$index].gys = event.value;
      this.rptProPaperpackStateList[scope.$index].gysname = event.label;
    },
    /** 查询纸包机操作记录列表 */
    getList() {
      this.loading = true;
      listPaperpack(this.queryParams).then((response) => {
        this.paperpackList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        rptName: null,
        rptTime: null,
        auditor: null,
        operator: this.nickName,
        code: "LK-QF-LS1-10-014-12-01",
        factory: "青岛崂山矿泉水有限公司",
        rptType: "纸包机",
        jjb: null,
        delFlag: null,
        remark: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
      };
      this.rptProPaperpackDayList = [];
      this.rptProPaperpackList = [];
      this.rptProPaperpackCheckList = [];
      this.rptProPaperpackStateList = [];
      this.rptProPaperpackWorkList = [];
      this.resetForm("form");

      const myDate = new Date();
      const year = myDate.getFullYear();
      const month = myDate.getMonth() + 1;
      const day = myDate.getDate();
      this.form.rptTime = `${year}-${month}-${day}`;
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      if (this.queryParams.rptTime != null) {
        let arr = this.queryParams.rptTime;
        this.queryParams.rptTime = arr[0];
        this.queryParams.rptTime1 = arr[1];
      }
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.openDisabled = false;
      this.open = true;
      this.isShowImageUpload = true;
      this.isShowImage = false;
      this.title = "添加纸包机操作记录";


    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      this.openDisabled = false;
      this.isShowImageUpload = true;
      this.isShowImage = false;
      const id = row.id || this.ids;
      getPaperpack(id).then((response) => {
        this.form = response.data;
        this.rptProPaperpackDayList = response.data.rptProPaperpackDayList;
        this.rptProPaperpackList = response.data.rptProPaperpackList;
        this.rptProPaperpackCheckList = response.data.rptProPaperpackCheckList;
        this.rptProPaperpackStateList = response.data.rptProPaperpackStateList;
        this.rptProPaperpackWorkList = response.data.rptProPaperpackWorkList;
        this.open = true;
        this.title = "修改纸包机操作记录";
      });
    },
    /** 查看按钮 */
    handleView(row) {
      this.reset();
      this.isShowImageUpload = false;
      this.isShowImage = true;
      this.openDisabled = true;
      const id = row.id || this.ids;
      getPaperpack(id).then((response) => {
        this.form = response.data;
        this.rptProPaperpackDayList = response.data.rptProPaperpackDayList;
        this.rptProPaperpackList = response.data.rptProPaperpackList;
        this.rptProPaperpackCheckList = response.data.rptProPaperpackCheckList;
        this.rptProPaperpackStateList = response.data.rptProPaperpackStateList;
        this.rptProPaperpackWorkList = response.data.rptProPaperpackWorkList;
        this.open = true;
        this.title = "查看纸包机操作记录";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          this.form.rptProPaperpackDayList = this.rptProPaperpackDayList;
          this.form.rptProPaperpackList = this.rptProPaperpackList;
          this.form.rptProPaperpackCheckList = this.rptProPaperpackCheckList;
          this.form.rptProPaperpackStateList = this.rptProPaperpackStateList;
          this.form.rptProPaperpackWorkList = this.rptProPaperpackWorkList;
          if (this.form.id != null) {
            updatePaperpack(this.form).then((response) => {
              this.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            const rLoading = this.openLoading();
            addPaperpack(this.form)
              .then((response) => {
                this.msgSuccess("新增成功");
                this.open = false;
                rLoading.close();
                this.getList();
              })
              .catch((error) => {
                rLoading.close();
              });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$confirm(
        '是否确认删除纸包机操作记录编号为"' + ids + '"的数据项?',
        "警告",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      )
        .then(function () {
          return delPaperpack(ids);
        })
        .then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 纸包机操作记录温度序号 */
    rowRptProPaperpackDayIndex({ row, rowIndex }) {
      row.index = rowIndex + 1;
    },
    /** 纸包机操作记录温度添加按钮操作 */
    handleAddRptProPaperpackDay() {
      let obj = {};
      obj.recordTime = "";
      obj.jxwd = "";
      obj.jgwd = "";
      obj.jqwd = "";
      obj.rrjxh = "";
      obj.rrjlyl = "";
      obj.rrjleft = "";
      obj.rrjsyl = "";
      obj.remark = "";
      this.rptProPaperpackDayList.push(obj);
    },
    /** 纸包机操作记录温度删除按钮操作 */
    handleDeleteRptProPaperpackDay() {
      if (this.checkedRptProPaperpackDay.length == 0) {
        this.$alert("请先选择要删除的纸包机操作记录温度数据", "提示", {
          confirmButtonText: "确定",
        });
      } else {
        this.rptProPaperpackDayList.splice(
          this.checkedRptProPaperpackDay[0].index - 1,
          1
        );
      }
    },
    /** 单选框选中数据 */
    handleRptProPaperpackDaySelectionChange(selection) {
      if (selection.length > 1) {
        this.$refs.rptProPaperpackDay.clearSelection();
        this.$refs.rptProPaperpackDay.toggleRowSelection(selection.pop());
      } else {
        this.checkedRptProPaperpackDay = selection;
      }
    },
    /** 纸包机操作记录时间序号 */
    rowRptProPaperpackIndex({ row, rowIndex }) {
      row.index = rowIndex + 1;
    },
    /** 纸包机操作记录时间添加按钮操作 */
    handleAddRptProPaperpack() {
      let obj = {};
      obj.productName = "";
      obj.startTime = "";
      obj.stopTime = "";
      obj.js = "";
      obj.remark = "";
      this.rptProPaperpackList.push(obj);
    },
    /** 纸包机操作记录时间删除按钮操作 */
    handleDeleteRptProPaperpack() {
      if (this.checkedRptProPaperpack.length == 0) {
        this.$alert("请先选择要删除的纸包机操作记录时间数据", "提示", {
          confirmButtonText: "确定",
        });
      } else {
        this.rptProPaperpackList.splice(
          this.checkedRptProPaperpack[0].index - 1,
          1
        );
      }
    },
    /** 单选框选中数据 */
    handleRptProPaperpackSelectionChange(selection) {
      if (selection.length > 1) {
        this.$refs.rptProPaperpack.clearSelection();
        this.$refs.rptProPaperpack.toggleRowSelection(selection.pop());
      } else {
        this.checkedRptProPaperpack = selection;
      }
    },
    /** 纸包机操作记录岗位自检情况序号 */
    rowRptProPaperpackCheckIndex({ row, rowIndex }) {
      row.index = rowIndex + 1;
    },
    /** 纸包机操作记录岗位自检情况添加按钮操作 */
    handleAddRptProPaperpackCheck() {
      let obj = {};
      obj.recordTime = "";
      obj.fxzl = "正常";
      obj.qpjc = "正常";
      obj.nhqk = "正常";
      obj.pm = "";
      obj.xm = "";
      obj.zxtxm = "";
      obj.remark = "";
      this.rptProPaperpackCheckList.push(obj);
    },
    /** 纸包机操作记录岗位自检情况删除按钮操作 */
    handleDeleteRptProPaperpackCheck() {
      if (this.checkedRptProPaperpackCheck.length == 0) {
        this.$alert("请先选择要删除的纸包机操作记录岗位自检情况数据", "提示", {
          confirmButtonText: "确定",
        });
      } else {
        this.rptProPaperpackCheckList.splice(
          this.checkedRptProPaperpackCheck[0].index - 1,
          1
        );
      }
    },
    /** 单选框选中数据 */
    handleRptProPaperpackCheckSelectionChange(selection) {
      if (selection.length > 1) {
        this.$refs.rptProPaperpackCheck.clearSelection();
        this.$refs.rptProPaperpackCheck.toggleRowSelection(selection.pop());
      } else {
        this.checkedRptProPaperpackCheck = selection;
      }
    },
    /** 纸包机操作记录纸箱使用情况序号 */
    rowRptProPaperpackStateIndex({ row, rowIndex }) {
      row.index = rowIndex + 1;
    },
    /** 纸包机操作记录纸箱使用情况添加按钮操作 */
    handleAddRptProPaperpackState() {
      let obj = {};
      obj.gys = null;
      obj.gysname = "";
      obj.bhenum = "";
      obj.bhgreason = "";
      obj.remark = "";
      this.rptProPaperpackStateList.push(obj);

      listEqpfactory().then((response) => {
        this.deptOptions = this.handleTree(response.data, "id");
      });
    },
    /** 纸包机操作记录纸箱使用情况删除按钮操作 */
    handleDeleteRptProPaperpackState() {
      if (this.checkedRptProPaperpackState.length == 0) {
        this.$alert("请先选择要删除的纸包机操作记录纸箱使用情况数据", "提示", {
          confirmButtonText: "确定",
        });
      } else {
        this.rptProPaperpackStateList.splice(
          this.checkedRptProPaperpackState[0].index - 1,
          1
        );
      }
    },
    /** 单选框选中数据 */
    handleRptProPaperpackStateSelectionChange(selection) {
      if (selection.length > 1) {
        this.$refs.rptProPaperpackState.clearSelection();
        this.$refs.rptProPaperpackState.toggleRowSelection(selection.pop());
      } else {
        this.checkedRptProPaperpackState = selection;
      }
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "report/paperpack/export",
        {
          ...this.queryParams,
        },
        "纸包机操作记录" + this.parseTime(new Date()) + ".xlsx"
      );
    },
    //接收编号
    nameChange(e) {
      this.form.code = e;
    },
    nameChange2(e) {
      this.form.factory = e;
    },
    /** 审核按钮操作 */
    handleCheck(row) {
      /* 审核 */
      this.ids.forEach((id) => {
        getPaperpack(id).then((response) => {
          if (response.data.auditor != null && response.data.auditor != "") {
            this.msgError(
              '编号为"' + id + '"的数据项已审核完成，无需重复审核！'
            );
          } else {
            let obj = {};
            obj.id = id;
            obj.auditor = this.nickName;

            obj.rptProPaperpackDayList = this.rptProPaperpackDayList;
            obj.rptProPaperpackList = this.rptProPaperpackList;
            obj.rptProPaperpackCheckList = this.rptProPaperpackCheckList;
            obj.rptProPaperpackStateList = this.rptProPaperpackStateList;
            obj.rptProPaperpackWorkList = this.rptProPaperpackWorkList;
            /* 修改 */
              checkPaperpack(obj).then((response) => {
              this.msgSuccess('编号为"' + id + '"的数据项审核成功！');
              this.getList();
            });
          }
        });
      });
    },
    excelhandleView(row){
      this.download(
        "Laboratory/paperpack/exportexcel?id="+row.id,
        {
          ...this.queryParams,
        },
        "纸包机操作记录" + this.parseTime(new Date()) + ".xlsx"
      );
    },
    /** 纸包机交接班序号 */
    rowRptProPaperpackWorkIndex({ row, rowIndex }) {
      row.index = rowIndex + 1;
    },
    /** 纸包机交接班添加按钮操作 */
    handleAddRptProPaperpackWork() {
      let obj = {};
      obj.recordTime = "";
      obj.recordTime2 = "";
      obj.workstate = "";
      obj.userid = "";
      obj.username = "";
      obj.remark = "";
      this.rptProPaperpackWorkList.push(obj);
    },
    /** 纸包机交接班删除按钮操作 */
    handleDeleteRptProPaperpackWork() {
      if (this.checkedRptProPaperpackWork.length == 0) {
        this.$alert("请先选择要删除的纸包机交接班数据", "提示", {
          confirmButtonText: "确定",
        });
      } else {
        this.rptProPaperpackWorkList.splice(
          this.checkedRptProPaperpackWork[0].index - 1,
          1
        );
      }
    },
    /** 单选框选中数据 */
    handleRptProPaperpackWorkSelectionChange(selection) {
      if (selection.length > 1) {
        this.$refs.rptProPaperpackWork.clearSelection();
        this.$refs.rptProPaperpackWork.toggleRowSelection(selection.pop());
      } else {
        this.checkedRptProPaperpackWork = selection;
      }
    },
    /* 查询用户列表 */
    queryUserList() {
      listUser().then((response) => {
        this.userList = response.rows;
      });
      getInfo().then((response) => {
        this.nickName = response.user.nickName;
      });
    },
  },
};
</script>
